package com.union.official.common.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 分页查询请求对象
 *
 * @author 杨 强
 * @package com.union.official.common.util
 * @createTime 2024-03-07 10:24
 */
@Data
@NoArgsConstructor
public class QueryVO {

    /*** 默认的每页显示行数*/
    public static final int DEFAULT_PAGE_SIZE = 10;

    @ApiModelProperty(value = "分页字段-页码")
    private int pageNum = 1;

    @ApiModelProperty(value = "分页字段-每页要显示的行数")
    private int pageSize = DEFAULT_PAGE_SIZE;

    @ApiModelProperty(value = "排序字段名")
    private String sort;

    @ApiModelProperty(value = "排序方向asc,desc")
    private String dir;


    public int getPageNum() {
        return pageNum > 0 ? pageNum : 1;
    }

    public int getPageSize() {
        return pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE;
    }

    public String getSort() {
        return sort;
    }

    public String getDir() {
        return dir;
    }
}
